<!DOCTYPE html>
<html class="no-js">
<head>
    <meta charset="utf-8">
    <title>会议室预约</title>
    <meta name="description" content="">
    <meta name="HandheldFriendly" content="True">
    <meta name="MobileOptimized" content="320">
    <meta name="viewport" content="width=device-width, initial-scale=1, minimal-ui, user-scalable=no">
    <meta http-equiv="cleartype" content="on">
    <meta name="format-detection" content="telephone=no">
    <link rel="stylesheet" href="/assets/meeting/css/style.css">
    <link rel="stylesheet" href="/assets/public/mobiscroll/css/mobiscroll.custom-3.0.0-beta2.min.css">
    <link rel="stylesheet" href="/assets/meeting/css/layer.css">
</head>
<body>
<div class="wraper normal" js="wapjs/meeting/js/panel">
    <div class="head clearfix">
        <a href="javascript:history.back(-1)" class="iconfont icon-zuo"></a>
        <span class="head-name">{BEESCRM:$roomInfo['room_name']}</span>
    </div>

    <div class="lists notopblock" style="padding: 8px 12px">
        <div class="panel-tab text-center clearfix">
            <a href="{BEESCRM::U('/meeting/meetingRoom/weekPanel',array('outDoor' => $outDoor,'account_id' => $accountId,'meeting_room_id' => $meetingRoomId,'showDetail' => $showDetail))}" class="tab-list actived pull-left">周看板</a>
            <a href="{BEESCRM::U('/meeting/meetingRoom/dayPanel',array('outDoor' => $outDoor,'account_id' => $accountId,'meeting_room_id' => $meetingRoomId,'showDetail' => $showDetail))}" class="tab-list pull-left">日看板</a>
        </div>
    </div>

    <div class="tab tab-fore clearfix">
        <a href="{BEESCRM::U('/meeting/meetingRoom/weekPanel',array('outDoor' => $outDoor,'date' => $date,'level' => 0,'account_id' => $accountId,'meeting_room_id' => $meetingRoomId,'showDetail' => $showDetail))}" class="tab-list <if condition='$level eq 0'>visited</if>">本周</a>
        <a href="{BEESCRM::U('/meeting/meetingRoom/weekPanel',array('outDoor' => $outDoor,'date' => $date,'level' => 1,'account_id' => $accountId,'meeting_room_id' => $meetingRoomId,'showDetail' => $showDetail))}" class="tab-list <if condition='$level eq 1'>visited</if>">下周</a>
        <a href="{BEESCRM::U('/meeting/meetingRoom/weekPanel',array('outDoor' => $outDoor,'date' => $date,'level' => 2,'account_id' => $accountId,'meeting_room_id' => $meetingRoomId,'showDetail' => $showDetail))}" class="tab-list <if condition='$level eq 2'>visited</if>">下下周</a>

        <a href="#" class="calendar text-right text-green pull-left">
            <span class="iconfont icon-rili"></span>
            <input id="day" class="input-hidden"/>
        </a>
    </div>
    <div class="panel daypanel text-12 clearfix">
        <foreach name="weekDate" item="vo">
            <div class="block text-gray bg-gray text-center pull-left">
                <p>{BEESCRM:$vo.date|date='m-d',###}</p>
                <p>周{BEESCRM:$vo.week}</p>
            </div>
       </foreach>

        <foreach name="weekDate" item="vo">
            <div class="block  bigblock pull-left" data-no="{BEESCRM:$vo['morning']['no']}">

                    <switch name="vo['morning']['status']">
                        <case value="0">
                            <p class="">上午</p>
                            <p class="status text-right">
                                <if condition="$roomInfo['status'] eq 2">
                                    <span class="child text-lebel text-center text-gray">禁用</span>
                                    <elseif condition="$roomInfo['status'] eq 3" />
                                    <span class="child text-lebel text-center text-gray">检修</span>
                                    <else />
                                    <span class="child" data-no="{BEESCRM:$vo['morning']['no']}"></span>
                                </if>

                            </p>
                        </case>
                        <case value="1">
                            <p class="text-gray">上午</p>
                            <p class="status">
                            <span class="child text-lebel text-center text-gray" >审批中</span>
                            </p>
                        </case>
                        <case value="2">
                            <p class="text-gray">上午</p>
                            <p class="status">
                            <span class="child text-lebel text-center text-gray">已预约</span>
                            </p>
                        </case>
                        <case value="10">
                            <p class="text-gray">上午</p>
                            <p class="status">
                            <span class="child time-out text-center text-gray"></span>
                            </p>
                        </case>
                    </switch>
            </div>
        </foreach>

        <foreach name="weekDate" item="vo">
            <div class="block bigblock pull-left" data-no="{BEESCRM:$vo['afternoon']['no']}">
                    <switch name="vo['afternoon']['status']">
                        <case value="0">
                            <p>下午</p>
                            <p class="status text-right" >
                                <if condition="$roomInfo['status'] eq 2">
                                    <span class="child text-lebel text-center text-gray">禁用</span>
                                    <elseif condition="$roomInfo['status'] eq 3" />
                                    <span class="child text-lebel text-center text-gray">检修</span>
                                    <else />
                                    <span class="child" data-no="{BEESCRM:$vo['afternoon']['no']}"></span>
                                </if>
                            </p>
                        </case>
                        <case value="1">
                            <p class = 'text-gray'>下午</p>
                            <p class="status" >
                                <span class="child text-lebel text-center text-gray" >审批中</span>
                            </p>
                        </case>
                        <case value="2">
                            <p class = 'text-gray'>下午</p>
                            <p class="status" >
                                <span class="child text-lebel text-center text-gray">已预约</span>
                            </p>
                        </case>
                        <case value="10">
                            <p class="text-gray">下午</p>
                            <p class="status" >
                                <span class="child time-out text-center text-gray"></span>
                            </p>
                        </case>
                    </switch>
                </p>
            </div>
        </foreach>

        <foreach name="weekDate" item="vo">
            <div class="block bigblock pull-left" data-no="{BEESCRM:$vo['night']['no']}">
                    <switch name="vo['night']['status']">
                        <case value="0">
                            <p >晚上</p>
                            <p class="status text-right">
                                <if condition="$roomInfo['status'] eq 2">
                                    <span class="child text-lebel text-center text-gray">禁用</span>
                                    <elseif condition="$roomInfo['status'] eq 3" />
                                    <span class="child text-lebel text-center text-gray">检修</span>
                                    <else />
                                    <span class="child" data-no="{BEESCRM:$vo['night']['no']}"></span>
                                </if>
                            </p>
                        </case>
                        <case value="1">
                            <p class = 'text-gray'>晚上</p>
                            <p class="status">
                                <span class="child text-lebel text-center text-gray" >审批中</span>
                            </p>
                        </case>
                        <case value="2">
                            <p class = 'text-gray'>晚上</p>
                            <p class="status">
                                <span class="child text-lebel text-center text-gray">已预约</span>
                            </p>
                        </case>
                        <case value="10">
                            <p class = 'text-gray'>晚上</p>
                            <p class="status">
                                <span class="child time-out text-center text-gray"></span>
                            </p>
                        </case>
                    </switch>
                </p>
            </div>
        </foreach>
    </div>

    <if condition="$meetingUser['organizer'] eq 1 and $showDetail neq 1">
        <neq name="outDoor" value="1">
            <a href="#" class="lists text-normal select-service">
                <span class="iconfont icon-jiudianwuxianhuatong32px text-green"></span> 请选择会议服务
                <span class="iconfont icon-you text-16 pull-right"></span>
            </a>
        </neq>

        <div class="bordertop" >
            <div class="flex-box text-12 facility hide">
                <p class="field">设施设备：</p>
                <p class="flex-item">

                </p>
            </div>
            <div class="flex-box text-12 property hide">
                <p class="field">会务服务：</p>
                <p class="flex-item">

                </p>
            </div>
            <div class="flex-box text-12 other hide">
                <p class="field">其他：</p>
                <p class="flex-item">

                </p>
            </div>
        </div>

        <div class="btn-box">
            <a href="javascript:void(0);" class="btn bg-green appoint">确认预约</a>
        </div>
    </if>
</div>

<input type="hidden" name="outDoor" id="outDoor" value="{BEESCRM:$outDoor}" />
<input type="hidden" name="showDetail" id="showDetail" value="{BEESCRM:$showDetail}" />
<input type="hidden" name="accountId" id="accountId" value="{BEESCRM:$accountId}" />
<input type="hidden" name="meetingRoomId" id="meetingRoomId" value="{BEESCRM:$meetingRoomId}" />
<script type="text/javascript" src="/assets/public/seajs/sea.js"></script>
<script enter="publicjs/public" id="confnode" async="async" src="/assets/public/config.js"></script>
<include file="new/panelservice" />
<script>
    $(document).on('click','.block',function() { //选择预约时间

        if('{BEESCRM:$roomInfo["status"]}' == 2 || '{BEESCRM:$roomInfo["status"]}' == 3) {
            fm.alert('当前会议室禁用或者检修中，请稍后预约...');return false;
        }

        if($("#showDetail").val() == 1) {
            return false;
        }

        if('{BEESCRM:$meetingUser["organizer"]}' != 1) {
            return false;
        }

        if($(this).find('.child').hasClass('text-gray')){
            fm.alert('该时段不可选~');
        } else {
            if($(this).find('.child').hasClass('icon-xuanze1')) {
                $(this).find('.child').removeClass('iconfont icon-xuanze1 text-green');
            } else {
                $(this).find('.child').addClass('iconfont icon-xuanze1 text-green');
            }
        }
    })

    $(document).on('click','.select-service',function() {
        $(".layer-wraper").show();
        $(".layermain").show();
    })

    $(document).on('click','.appoint',function() { //确认预约
        var data = {};
        var no = [];
        var device = [];
        if($(".icon-xuanze1").length == 0) {
            fm.alert('请选择预约时间');return false;
        } else{
            $(".icon-xuanze1").each(function() {
                no.push($(this).data('no'));
            })
            no.sort();
            var i = 0;
            for(i=0;i<no.length-1;i++) {
                if(no[i] + 1 != no[i+1]) {
                    fm.alert('请选择连续的时间~');return false;
                }
            }
            if(no.length >= 2) {
                if(parseInt((no[0]-1)/3) != parseInt((no[no.length-1]-1)/3)) {
                    fm.alert('不能跨天选择时间~');return false;
                }
            }

        }

        $(".count").each(function() {
            device.push([$(this).data('device_id'),$(this).val()]);
        })
        data.device = device;
        data.no = no;
        data.level = '{BEESCRM:$level}';
        data.meeting_room_id = '{BEESCRM:$meetingRoomId}';
        data.panel_type = $("#panelType").val();
        data.date = $("#date").val();
        data.remark_text = $("#remarkText").val();
        console.log(data);

        $.ajax({
            url: '/meeting/meetingRoom/sureRoomAndService/account_id/{BEESCRM:$accountId}',
            type: 'post',
            data: data,
            dataType: 'json',
            success:function(data) {
                if(data.status == 'S') {
                    $("#service").html(data.message);
                    $(".servicePop").show();
                    if($("#outDoor").val() == 1) {
                        window.location.href = '/meeting/MeetingOutDoorBespeak/add/meeting_room_id/{BEESCRM:$meetingRoomId}/account_id/{BEESCRM:$accountId}';
                    } else {
                        window.location.href = '/meeting/meetingInvite/addInviteMeeting/account_id/{BEESCRM:$accountId}';
                    }
                } else if(data.status == 'F') {
                    fm.alert(data.message);
                }
            }
        });
    })

</script>
</body>
</html>